#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "common.h"
#include <QMenu>

class QActionGroup;
class AttributeWidget;
class ComponentWidget;
class StationWidget;
class StructureWidget;
class ShowWidget;
class EditWidget;
class DynamicMapManageWindow;
class ConfigWidget;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void GenerateRoute();//生成上行线路
    void ReloadMainWay();//生成上行线路不包含单个控件
    void AddSingleView(int x, int y, int w, int h, QString object_name, EditWidget *edit, QString file_name);
    QFileInfoList getFileList(const QString&);
    void GenerateEditFromXml(const QString&);
    void SaveJson();
    bool ParseProjectJsonFile(const QString&, const QString&);
    void AutoGenerateFromUp();
    void AutoGenerateArriveOneFromUp();
    void SetMenuVisable();
    void AutoGenerateArriveAllStationFromOne();
    void GenerateArriveFromStationOne();
public slots:
    void delete_object(QString id);
    void copy_object(QString file_name, QString object_name, QString random);
    void set_curr_show_filename(QString file_name);
    void ReloadMainWayFromConfig();
signals:

protected:
    void on_mouseDoubleClick(QPoint point);
    void closeEvent(QCloseEvent *event);

private slots:
    void menu_action(QAction *action);

private:
    ComponentWidget *component_widget;
    StationWidget *station_widget;
    ShowWidget *show_widget;
    StructureWidget *struture_widget;
    AttributeWidget *attribute_widget;
    ConfigWidget *config_widget;

    QMenuBar    *menu_bar;
    QMenu       *menu_file;
    QMenu       *menu_source;
    QActionGroup *action_group;

    QString mCurrShowFilename;

private:
    void save_project();
    void create_project();
    void create_file();
    void open_project(QString jsonFile = QString());
    void slt_create_item(ObjectInfo info, QPoint pos);
    void saveaAllProject();
    bool createFoler(QDir *folder, QString file_name);
    void CopyRunDown(QString up_name, QWidget *widget);
    void CopyMirror(QString nonmirror_name, QWidget *widget);
    void GenerateRunDown();
    void GenerateMirror();
    void GenerateRunDownArriveOne();
    void GenerateMirrorArriveOne();
    void AutoLoadSource();
    void LoadFile();
    void addsource(QString file_name, QWidget *widget);
    void GetSrcSize(const QString flag, AutoData *data);
    void show_component();
    void clearSouece();
    void createSourceFilder();
    void createEditWidgets();
    bool isCreatedProject();
};
#endif // MAINWINDOW_H
